package org.thread.test05.demo04;

/**
 * @author ZJL
 * @date 2025-03-12
 */
public class MyRunnable implements Runnable {
    private Printer user;
    private String outPut;
    private String lock = "";

    public MyRunnable(Printer user, String outPut) {
        this.user = user;
        this.outPut = outPut;
    }

    @Override
    public void run() {
        printInput(user, outPut);
    }

    private static synchronized void printInput(Printer user, String outPut) {
        user.setPrint(outPut);
        System.out.println(Thread.currentThread().getName() + ":" + user.getPrint());
    }

}
